import { debounce } from "lodash"
const directive = {
    mounted(el, binding) {
        if (typeof binding.value !== "function") {
            throw "callback must be a function"
        }
        el.debounceClick = debounce(binding.value, 300, {
            leading: true,
            trailing: false,
        })
        el.addEventListener("click", el.debounceClick)
    },
    onUnmounted(el) {
        el.removeEventListener("click", el.debounceClick)
    },
}
export default directive
